package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.RecordPicture;
import com.ruoyi.business.service.IRecordPictureService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 识别图片Controller
 * 
 * @author asher
 * @date 2021-11-28
 */
@RestController
@RequestMapping("/business/record_picture")
public class RecordPictureController extends BaseController
{
    @Autowired
    private IRecordPictureService recordPictureService;

    /**
     * 查询识别图片列表
     */
    @PreAuthorize("@ss.hasPermi('business:record_picture:list')")
    @GetMapping("/list")
    public TableDataInfo list(RecordPicture recordPicture)
    {
        startPage();
        List<RecordPicture> list = recordPictureService.selectRecordPictureList(recordPicture);
        return getDataTable(list);
    }

    /**
     * 导出识别图片列表
     */
    @PreAuthorize("@ss.hasPermi('business:record_picture:export')")
    @Log(title = "识别图片", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RecordPicture recordPicture)
    {
        List<RecordPicture> list = recordPictureService.selectRecordPictureList(recordPicture);
        ExcelUtil<RecordPicture> util = new ExcelUtil<RecordPicture>(RecordPicture.class);
        return util.exportExcel(list, "识别图片数据");
    }

    /**
     * 获取识别图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:record_picture:query')")
    @GetMapping(value = "/{recordPictureId}")
    public AjaxResult getInfo(@PathVariable("recordPictureId") Long recordPictureId)
    {
        return AjaxResult.success(recordPictureService.selectRecordPictureByRecordPictureId(recordPictureId));
    }

    /**
     * 新增识别图片
     */
    @PreAuthorize("@ss.hasPermi('business:record_picture:add')")
    @Log(title = "识别图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecordPicture recordPicture)
    {
        return toAjax(recordPictureService.insertRecordPicture(recordPicture));
    }

    /**
     * 修改识别图片
     */
    @PreAuthorize("@ss.hasPermi('business:record_picture:edit')")
    @Log(title = "识别图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RecordPicture recordPicture)
    {
        return toAjax(recordPictureService.updateRecordPicture(recordPicture));
    }

    /**
     * 删除识别图片
     */
    @PreAuthorize("@ss.hasPermi('business:record_picture:remove')")
    @Log(title = "识别图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordPictureIds}")
    public AjaxResult remove(@PathVariable Long[] recordPictureIds)
    {
        return toAjax(recordPictureService.deleteRecordPictureByRecordPictureIds(recordPictureIds));
    }
}
